<!-- <template>
  <div>
    <el-upload
  class="avatar-uploader"
  action="http://upload-z1.qiniup.com/"
  :show-file-list="false"
  :data="shuju"
  :on-success="handleAvatarSuccess"
  :before-upload="beforeAvatarUpload">
  <img v-if="imageUrl" :src="imageUrl" class="avatar" @click="getToken">
  <i v-else class="el-icon-plus avatar-uploader-icon" @click="getToken"></i>
</el-upload>


显示上传后的图片
<img :src="showurl" width="200px" height="200px"/>
   </div>
</template>



<style>
  .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
  }
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
</style>

<script>
import axios from 'axios';
  export default {
    data() {
      return {
        imageUrl: '',
        shuju:{
            key:"",
            token:""
        },
        showurl:""
      };
    },
    mounted(){
        console.log("打印");
    },
    methods: {
      handleAvatarSuccess(res, file) {
        console.log(res);//上传成功后返回值json{"hash":"FphhkBU4u7F36rDb58cqK3fCmloD","key":"testd705686f-d42a-4991-a55f-9b6479f65e55"}
        this.imageUrl = URL.createObjectURL(file.raw);
        this.showurl="http://rkefqov0b.hb-bkt.clouddn.com/"+res.key;

      },
      beforeAvatarUpload(file) {
        const isJPG = file.type === 'image/jpeg';
        const isLt2M = file.size / 1024 / 1024 < 2;

        if (!isJPG) {
          this.$message.error('上传头像图片只能是 JPG 格式!');
        }
        if (!isLt2M) {
          this.$message.error('上传头像图片大小不能超过 2MB!');
        }
       
        return isJPG && isLt2M;
      }
      ,
      getToken(){
        axios.get("/chain-api/uuzi/getToken/awdawdawsefgwse").then(res=>{
            this.shuju.token = res.data.data.token;
            this.shuju.key = res.data.data.fname;
            console.log(res);
        });
      }
    },
    
  }
</script> -->